package com.example.demo.controller;

import com.example.demo.pojo.PageResult;
import com.example.demo.pojo.Result;
import com.example.demo.pojo.Setting;
import com.example.demo.service.Impl.SettingServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class SettingController {
    @Autowired
    private SettingServiceImpl settingService;
    //查询配置项
    @GetMapping("/systemset")
    public Result settingSelect(String key){
        List<Setting> setting = settingService.settingSelect(key);
        return PageResult.success02(setting);
    }
    //删除配置项
    @DeleteMapping("/systemset")
    public Result settingDelete(Integer id){
        settingService.deleteSetting(id);
        return Result.success("删除成功");
    }
    //修改配置项
    @PutMapping("/systemset")
    public Result settingUpdate(@RequestBody Setting setting){
        settingService.updateSetting(setting);
        return Result.success("修改成功");
    }
}
